package yf.platform.biz;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import yf.platform.bo.BizResult;


public class ChartService extends Service {
	
	public BizResult demo(Map<String,String> input) throws Throwable{
		List<Map<String,Object>> charts = new ArrayList<Map<String,Object>>();
		for(int i =0;i<3;i++){
			Map<String,Object> chart = new HashMap<String,Object>();
			JSONObject testLabels = new JSONObject();
			//["January","February","March","April","May","June","July"],
			testLabels.put("1", "January");
			testLabels.put("2", "February");
			testLabels.put("3", "March");
			testLabels.put("4", "April");
			testLabels.put("5", "May");
			testLabels.put("6", "June");
			testLabels.put("7", "July");
			JSONArray a = new JSONArray();
			a.addAll(testLabels.values());
			chart.put("title", "测试报表"+i);
			chart.put("labels", a.toString());
			chart.put("type", "Line");
			a.clear();
			a.addAll(testLabels.keySet());
			chart.put("keys", a.toString());
			Arrays.toString(testLabels.values().toArray()).replace("(", ")");
			JSONArray values = new JSONArray();
			//[65,59,90,81,56,55,40]
			JSONObject v = new JSONObject();
			v.put("1", 65*i);
			v.put("2", 65*i);
			v.put("3", 65*i);
			v.put("4", 65*i);
			v.put("5", 15);
			v.put("6", 65*i);
			v.put("7", 65*i);
			values.add(v);
			chart.put("values", values);
			
			charts.add(chart);
		}
		return rst.setCode(0).setReqAttribute("charts", charts)
				.setType(BizResult.REDIRECT)
				.setPage("WIDGETS/CHART/demo.jsp");
	}
	

}
